<?php

if(isset($_POST["action"])&&$_POST["action"]=="ajouter") {

	$creation = new creation($_POST['modele'], $_POST['cat1'],$_POST['cat2'],$_POST['taille'],$_POST['description'],$_POST['dispo'],$_POST['prix']);
	$erreursCreation = $creation->getErreurs();

	if($creation->isValid()){
// 		echo 'ajout valid&eacute;';
		//ajout dans la BD
		$idCreation = $creation->ajoutBD();
// 		creation du dossier de photos
		mkdir('images/creations/'.$idCreation.'/', 0777, true);
		header("Location:ajoutPhoto.php?idCreation=".$idCreation);
		exit();
	}

}
if(isset($_POST["action"]) && $_POST["action"]=="modifier" && isset($_POST["idCreation"])) {
	
	$idCreation = $_POST["idCreation"];	
	$creation = new creation($_POST['modele'], $_POST['cat1'],$_POST['cat2'],$_POST['taille'],$_POST['description'],$_POST['dispo'],$_POST['prix']);
	$erreursCreation = $creation->getErreurs();
	
	if($creation->isValid()){
		$idCreation = $creation->modifBD($idCreation);
		header("Location:ajoutPhoto.php?idCreation=".$idCreation);
		exit();
	}
}
// if(isset($_POST["action"]) && $_POST["action"]=="supprimer" && isset($_POST["idCreation"])) {
// 	creation::supprBD($_POST["idCreation"]);
// }
?>